package com.smt.ejb3.tutoria.client;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import com.smt.ejb3.tutoria.extendedpersistencecontext.Student;
import com.smt.ejb3.tutoria.extendedpersistencecontext.StudentManager;

public class StudentClient {
	public static void main(String[] args) {
		
		Student stu = new Student();
		stu.setName("Old Sun2");
		stu.setAge(22);
		stu.setAddress("13 Bondfield st");
		
		try {
			InitialContext ctx = new InitialContext();

			StudentManager manager = (StudentManager) ctx
					.lookup("StudentManagerBean/remote");
			
			manager.saveStudent(stu);
			stu = manager.findStudent(2);
			
			System.out.println(stu.getId()+" "+stu.getName()+" "
					+stu.getAge()+" "+stu.getAddress());
			System.out.println("-----------");
			
			manager.updateName("Old Chang");
			stu = manager.findStudent(2);
			System.out.println(stu.getId()+" "+stu.getName()+" "
					+stu.getAge()+" "+stu.getAddress());
			
			
			
		} catch (NamingException ex) {
			ex.printStackTrace();
		}
	}
}
